﻿using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using System.ComponentModel;
using Kingdee.BOS.App.Core;
using Kingdee.BOS.ServiceHelper;
using Newtonsoft.Json;
using System.Collections.Generic;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.Bill.PlugIn.Args;
using System;



namespace Kingdee.SR.Plugin
{
    [Description("【服务插件】通过内码获取单据数据包"), HotUpdate]
    public class Test1PlugIn : AbstractOperationServicePlugIn
    {
        public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
        {
            base.BeforeExecuteOperationTransaction(e);
            var pkid = 110047;
            var data1 = new ViewService().LoadSingle(this.Context, pkid, this.BusinessInfo.GetDynamicObjectType());
            WriteLog.Write(JsonConvert.SerializeObject(data1));

            var data2 = new ViewService().LoadSingle(this.Context, pkid, this.BusinessInfo.GetSubBusinessInfo(new List<string>(new[] { "FBillNo", "FDate", "FBillTypeID", "FDocumentStatus", "FCreateDate"  })).GetDynamicObjectType());
            WriteLog.Write(JsonConvert.SerializeObject(data2));
        }
    }

    [Description("【表单插件】更新字段刷新页面"), HotUpdate]
    public class Test2PlugIn : AbstractBillPlugIn
    {
        public override void BeforeSave(BeforeSaveEventArgs e)
        {
            base.BeforeSave(e);
            this.View.Model.SetValue("FNote", DateTime.Now);
            this.View.UpdateView("FNote");
            //var pkid = 110047;
            //var data1 = new ViewService().LoadSingle(this.Context, pkid, this.View.BusinessInfo.GetDynamicObjectType());
            //WriteLog.Write(JsonConvert.SerializeObject(data1));
        }

    }
}
